import { useEventBus, type EventBusListener } from "@vueuse/core"
import { onBeforeUnmount } from "vue"

type chatBus = 'showDialog' | 'showPaper' | 'refreshDiaglogName' | 'setEnhence' | 'setMenuList' | 'clearIntervalValue' |'pageIndexClick' | 'createdNewChat'


export function useChatBus(callback: EventBusListener<chatBus, any>) {
    const bus = useEventBus<chatBus>('')
    const unsub = bus.on(callback)
    onBeforeUnmount(unsub)
    return bus
}